#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
#include <signal.h>
int main(int argc, char const *argv[])
{
        int n = 5;
        int i = 0;
        pid_t pid3,pid;
        for (i = 0; i < n; i++){
                pid = fork();
                if(pid == 0){
                        break;
                }
                if(i == 2){
                        pid3 = pid;
                }
        }
        if(i < 5){
                //son
                while (1){
                        printf("I am child, pid=%d,ppid=%d\n", getpid(),getppid());
                        sleep(3);
                }
        }else if(i == n){
                //parent
                printf("I am parent,pid=%d, I will kill xiao san pid3=%d\n", pid,pid3);
                sleep(5);
                kill(pid3,SIGKILL);
                while (1){
                        sleep(1);
                }
        }
        return 0;
}
